package top.infopub.mgr.mkt.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.infopub.dto.bpa.BpaPublicProInfoDto;
import top.infopub.generic.GenericDao;
import top.infopub.generic.GenericServiceImpl;
import top.infopub.mgr.mkt.dao.ProjectInfoDao;
import top.infopub.mgr.mkt.service.ProjectInfoService;
import top.infopub.model.mkt.ProjectInfo;
import top.infopub.security.util.SessionUserUtils;
import top.infopub.security.vo.AuthorizationVO;

@Service
public class ProjectInfoServiceImpl extends GenericServiceImpl<ProjectInfo, String> implements ProjectInfoService {

    @Autowired
    private ProjectInfoDao projectInfoDao;
    @Override
    public GenericDao<ProjectInfo, String> getDao() {
        return projectInfoDao;
    }

    @Override
    public ProjectInfo findByProCode(String proCode) {
       return projectInfoDao.findByProCode(proCode);
    }

    @Override
    public ProjectInfo selectByProName(String proName) {

        return projectInfoDao.selectByProName(proName);
    }

    @Override
    public BpaPublicProInfoDto queryBpaProInfoByProCode(String proCode) {
        AuthorizationVO vo = SessionUserUtils.getSessionAttributeForUserDtl();
        BpaPublicProInfoDto proInfo = projectInfoDao.queryBpaProInfoByProCode(proCode);
        if (proInfo == null) proInfo = new BpaPublicProInfoDto();
        BpaPublicProInfoDto applyInfo = projectInfoDao.queryApplyInfo(vo.getId());
        proInfo.setApplyStaffName(applyInfo.getApplyStaffName());
        proInfo.setApplyDeptName(applyInfo.getApplyDeptName());
        proInfo.setApplyCompName(applyInfo.getApplyCompName());
        return proInfo;
    }
}
